(function($) {

//Little aid to determine if placeholder is supported.
    $.support.placeholder = (function() {
        var i = document.createElement('input');
        return 'placeholder' in i;
    })();

    if (!$.support.placeholder) {
        alert();
        var originalVal = this.originalVal = $.fn.val;
        $.fn.val = function(value) {
            if (typeof value === 'undefined') {
                var placeholder = $(this).attr("placeholder");
                var thisValue = originalVal.call(this);
                if (thisValue === placeholder)
                    return "";
                else
                    return originalVal.call(this);
            }
            else {
                return originalVal.call(this, value);
            }
        };
    }

    $.fn.placeholderForIE = function(args) {
        var returnValue = this;

        if (args === "value") {
            var element = $(this).first();
            var placeholder = $(element).attr("placeholder");
            var value = $(element).val();
            if (value === placeholder) {
                returnValue = "";
            } else {
                returnValue = value;
            }
        } else {
            if (!$.support.placeholder) {
                var selected = this; //This this is the selected element(s) to which the function is being applied.

                $(selected).each(function() {
                    element = this; //This this is the actual individual element to which the "each" function is being applied.

                    $(this).val($(this).attr("placeholder"));
                    $(this).addClass("placeholder");

                    $(element).focus(function() {
                        var placeholder = $(this).attr("placeholder");
                        var value = $(this).val();

                        if (value === placeholder || value === "") {
                            $(this).val("");
                            $(this).removeClass("placeholder");
                        }
                    });

                    $(element).blur(function() {
                        var placeholder = $(this).attr("placeholder");
                        var value = $(this).val();

                        if (value === "") {
                            $(this).val(placeholder);
                            $(this).addClass("placeholder");
                        }
                    });
                });

                returnValue = this;
            }
        }

        return returnValue;
    };

})(jQuery);




